package com.itheima.mapper;


import com.itheima.pojo.Setmeal;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface SetmealDao {



    void add(Setmeal setmeal);

    void setSetmealAndCheckGroup(Integer id, Integer[] checkGroupIds);

    @Select("SELECT * FROM t_setmeal WHERE code = #{code} AND name = #{name}")
    List<Setmeal> findByCodeAndName(String code, String name);

    void edit(Setmeal setmeal);

    @Delete("delete from t_setmeal_checkgroup where setmeal_id = #{id}")
    void deleteSetmealAndCheckGroup(Integer id);

    @Select("SELECT * FROM t_setmeal WHERE id = #{id}")
    Setmeal findById(Integer id);

    @Select("SELECT checkgroup_id FROM t_setmeal_checkgroup WHERE setmeal_id = #{id}")
    List<Integer> findCheckGroupIdsBySetmealId(Integer id);

    List<Setmeal> findPage(int start, int end, String queryString);

    @Select("SELECT COUNT(*) FROM t_setmeal")
    Long findCount();

    @Select("SELECT checkgroup_id FROM t_setmeal_checkgroup WHERE setmeal_id = #{id}")
    List<Integer> findCheckGroupId(Integer id);

//    @Select("SELECT * FROM t_checkgroup WHERE id = #{id}")
//    CheckGroup findCheckGroupById(Integer id);

    @Select("SELECT img FROM t_setmeal")
    List<String> findAllImgURL();

    @Select("SELECT * FROM t_setmeal")
    List<Setmeal> getSetmeal();
}
